home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / mainbvb4 / mailnblk.frm < prev    next >
Text File  |  1997-10-01  |  8KB  |  269 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H00C0C0C0&
  5.    Caption         =   "Non-Blocking Sample"
  6.    ClientHeight    =   3675
  7.    ClientLeft      =   3360
  8.    ClientTop       =   3105
  9.    ClientWidth     =   5640
  10.    BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  11.       Name            =   "MS Sans Serif"
  12.       Size            =   8.25
  13.       Charset         =   0
  14.       Weight          =   700
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    Height          =   4080
  21.    Left            =   3300
  22.    LinkTopic       =   "Form1"
  23.    ScaleHeight     =   3675
  24.    ScaleWidth      =   5640
  25.    Top             =   2760
  26.    Width           =   5760
  27.    Begin VB.TextBox Text4 
  28.       Appearance      =   0  'Flat
  29.       Height          =   1575
  30.       Left            =   600
  31.       MultiLine       =   -1  'True
  32.       TabIndex        =   7
  33.       Top             =   1440
  34.       Width           =   4215
  35.    End
  36.    Begin VB.CommandButton Command1 
  37.       Appearance      =   0  'Flat
  38.       BackColor       =   &H80000005&
  39.       Caption         =   "Send Message"
  40.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  41.          Name            =   "MS Sans Serif"
  42.          Size            =   8.25
  43.          Charset         =   0
  44.          Weight          =   400
  45.          Underline       =   0   'False
  46.          Italic          =   0   'False
  47.          Strikethrough   =   0   'False
  48.       EndProperty
  49.       Height          =   375
  50.       Left            =   1440
  51.       TabIndex        =   3
  52.       Top             =   3120
  53.       Width           =   2175
  54.    End
  55.    Begin VB.TextBox Text3 
  56.       Appearance      =   0  'Flat
  57.       Height          =   285
  58.       Left            =   1560
  59.       TabIndex        =   2
  60.       Top             =   840
  61.       Width           =   2175
  62.    End
  63.    Begin VB.TextBox Text2 
  64.       Appearance      =   0  'Flat
  65.       Height          =   285
  66.       Left            =   1560
  67.       TabIndex        =   1
  68.       Top             =   480
  69.       Width           =   2175
  70.    End
  71.    Begin VB.TextBox Text1 
  72.       Appearance      =   0  'Flat
  73.       Height          =   285
  74.       Left            =   1560
  75.       TabIndex        =   0
  76.       Top             =   120
  77.       Width           =   2175
  78.    End
  79.    Begin MailLib.mMail Mail1 
  80.       Left            =   0
  81.       Top             =   1440
  82.       _Version        =   327680
  83.       _ExtentX        =   847
  84.       _ExtentY        =   847
  85.       _StockProps     =   0
  86.       Blocking        =   0   'False
  87.       Debug           =   0
  88.       Host            =   ""
  89.       Timeout         =   0
  90.       ConnectType     =   0
  91.       PopPort         =   110
  92.       SmtpPort        =   25
  93.    End
  94.    Begin VB.Label Label4 
  95.       Alignment       =   1  'Right Justify
  96.       Appearance      =   0  'Flat
  97.       BackColor       =   &H00C0C0C0&
  98.       Caption         =   "Message:"
  99.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  100.          Name            =   "MS Sans Serif"
  101.          Size            =   8.25
  102.          Charset         =   0
  103.          Weight          =   400
  104.          Underline       =   0   'False
  105.          Italic          =   0   'False
  106.          Strikethrough   =   0   'False
  107.       EndProperty
  108.       ForeColor       =   &H80000008&
  109.       Height          =   255
  110.       Left            =   480
  111.       TabIndex        =   8
  112.       Top             =   1200
  113.       Width           =   975
  114.    End
  115.    Begin VB.Label Label3 
  116.       Alignment       =   1  'Right Justify
  117.       Appearance      =   0  'Flat
  118.       BackColor       =   &H00C0C0C0&
  119.       Caption         =   "Subject:"
  120.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  121.          Name            =   "MS Sans Serif"
  122.          Size            =   8.25
  123.          Charset         =   0
  124.          Weight          =   400
  125.          Underline       =   0   'False
  126.          Italic          =   0   'False
  127.          Strikethrough   =   0   'False
  128.       EndProperty
  129.       ForeColor       =   &H80000008&
  130.       Height          =   255
  131.       Left            =   240
  132.       TabIndex        =   6
  133.       Top             =   840
  134.       Width           =   1215
  135.    End
  136.    Begin VB.Label Label2 
  137.       Alignment       =   1  'Right Justify
  138.       Appearance      =   0  'Flat
  139.       BackColor       =   &H00C0C0C0&
  140.       Caption         =   "SMTP Server:"
  141.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  142.          Name            =   "MS Sans Serif"
  143.          Size            =   8.25
  144.          Charset         =   0
  145.          Weight          =   400
  146.          Underline       =   0   'False
  147.          Italic          =   0   'False
  148.          Strikethrough   =   0   'False
  149.       EndProperty
  150.       ForeColor       =   &H80000008&
  151.       Height          =   255
  152.       Left            =   120
  153.       TabIndex        =   5
  154.       Top             =   480
  155.       Width           =   1335
  156.    End
  157.    Begin VB.Label Label1 
  158.       Alignment       =   1  'Right Justify
  159.       Appearance      =   0  'Flat
  160.       BackColor       =   &H00C0C0C0&
  161.       Caption         =   "To:"
  162.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  163.          Name            =   "MS Sans Serif"
  164.          Size            =   8.25
  165.          Charset         =   0
  166.          Weight          =   400
  167.          Underline       =   0   'False
  168.          Italic          =   0   'False
  169.          Strikethrough   =   0   'False
  170.       EndProperty
  171.       ForeColor       =   &H80000008&
  172.       Height          =   255
  173.       Left            =   240
  174.       TabIndex        =   4
  175.       Top             =   120
  176.       Width           =   1215
  177.    End
  178. End
  179. Attribute VB_Name = "Form1"
  180. Attribute VB_Creatable = False
  181. Attribute VB_Exposed = False
  182.     Dim iState As Integer
  183.  
  184.  
  185. Private Sub Command1_Click()
  186.     
  187.     On Error GoTo Some_Err
  188.  
  189.     'validate entries
  190.     If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Then
  191.         MsgBox "Please fill in all values.", vbExclamation, "Missing Value"
  192.         Exit Sub
  193.     End If
  194.     
  195.     Mail1.Debug = 1
  196.     
  197.     'create a new message
  198.     Mail1.Action = MailActionNewMessage
  199.     Mail1.Date = Format$(Now, "ddd, dd mmm yyyy hh:mm:ss")
  200.     '
  201.     'Your user friendly name
  202.     Mail1.From = "Your Name"
  203.     '
  204.     'The return e-mail address
  205.     Mail1.EMailAddress = "you@yourdomain.com"
  206.     '
  207.     'the lucky recipient
  208.     Mail1.To = Text1.Text
  209.     Mail1.Subject = Text3.Text
  210.  
  211.     'create the headers for the message
  212.     '
  213.     Mail1.Body(0) = Text4.Text
  214.     
  215.     'basic host configuration
  216.     Mail1.Blocking = False
  217.     Mail1.Host = Text2.Text
  218.     Mail1.ConnectType = 0 'MailConnectTypeSMTP
  219.  
  220.     'send the message
  221.     Command1.Enabled = False
  222.     MousePointer = 11
  223.     iState = MailActionConnect
  224.     Mail1.Action = MailActionConnect
  225.     'the Done event of the Mail control handles the
  226.     'next actions
  227.     Exit Sub
  228.  
  229. Some_Err:
  230.     MsgBox CStr(Err)
  231.     On Error Resume Next
  232.     Mail1.Action = MailActionDisconnect
  233.     MousePointer = 0
  234.     Command1.Enabled = True
  235. End Sub
  236.  
  237. Private Sub Mail1_AsyncError(ByVal ErrorCode As Integer, ByVal ErrorMsg As String)
  238.     MsgBox "AsyncError: " & CStr(ErrorCode) & " - " & ErrorMsg
  239.     On Error Resume Next
  240.     iState = MailActionDisconnect
  241.     Mail1.Action = iState
  242. End Sub
  243.  
  244. Private Sub Mail1_Debug(ByVal Message As String)
  245.     Debug.Print Message
  246. End Sub
  247.  
  248. Private Sub Mail1_Done()
  249.     Select Case iState
  250.         Case MailActionConnect
  251.             Me.Caption = "Connected. Writing message..."
  252.             Mail1.Flags = MailDstIsHost
  253.             iState = MailActionWriteMessage
  254.             Mail1.Action = iState
  255.         Case MailActionWriteMessage
  256.             Me.Caption = "Message sent. Disconnecting..."
  257.             iState = MailActionDisconnect
  258.             Mail1.Action = iState
  259.         Case MailActionDisconnect
  260.             Me.Caption = "Disconnected!"
  261.             MousePointer = 0
  262.             Command1.Enabled = True
  263.